home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / cfuncs.zip / FNDDATE.C < prev    next >
Text File  |  1991-08-08  |  2KB  |  70 lines

  1. #include <string.h>
  2. #include "funcs.h"
  3. extern int FG, BG;
  4.  
  5. /*---------------------finddate---------------------------------*/
  6. /*DESCRIPTION:    Puts the system date or a user entered date into*/
  7. /*    datestr according to the value of format.        */
  8. /*                                */
  9. /*INPUT:                             */
  10. /*  ReturnFormat -- format to return the date in according to    */
  11. /*    ConvertDate formats.                    */
  12. /*  IncomingFormat -- format the date is in when passed to the  */
  13. /*      function.  This is the date that will be displayed    */
  14. /*                                */
  15. /*  If the incoming date is invalid (an empty string) the system*/
  16. /*    date will be used.                    */
  17. /*                                                              */
  18. /*RETURNS: 0 on sucess                        */
  19. /*       -1 on failure                    */
  20. /*USES: Frame, inout, ConvertDate,                */
  21. /*--------------------------------------------------------------*/
  22.  
  23. finddate(void *the_date, int ReturnFormat, int IncomingFormat, char *prompt)
  24. {
  25.     int   ret;
  26.     char  datestr[9];
  27.     char  PromptLine[40];
  28.     FrameDataType    Fr;
  29.  
  30.     /* if incoming date is bad or invalid, take system date */
  31.     if(ConvertDate(datestr, the_date, 6, IncomingFormat) ||
  32.             IncomingFormat==0 && *((unsigned *)the_date)==0)
  33.         ConvertDate(datestr, &ret, 6, 1);
  34.  
  35.     do{
  36.         Fr.X = 23; Fr.Y = 7;
  37.         Fr.F = (FG==-1)? 1: FG;
  38.         Fr.B = (BG==-1)? 2: BG;
  39.         Fr.L = 11; Fr.W = 34;
  40.         Fr.clear = 2;
  41.         Frame(&Fr);
  42.  
  43.         if((ret=strlen(prompt)) >= Fr.W)
  44.             Fr.txt[0] = prompt;
  45.         else
  46.         {
  47.             strspc(PromptLine, (Fr.W-ret)/2);
  48.             Fr.txt[0] = strcat(PromptLine, prompt);
  49.             /*sprintf(PromptLine, "%*s%s", (Fr.W-ret)/2, "",
  50.                 prompt);
  51.             Fr.txt[0] = PromptLine;*/
  52.         }
  53.  
  54.         Fr.txt[4] = "        -> Enter another Date";
  55.         Fr.txt[5] = "  ENTER -> Accept Date";
  56.         Fr.txt[6] = "    Esc -> Previous Screen";
  57.         Frame(&Fr);
  58.         inout(35, 10, 8, (FG==-1)? 1: FG, (BG==-1)? 2: BG, datestr, 2, 4, 1, "   ", &ret);
  59.         if(ret == 14) return(-1);
  60.     } while (ConvertDate(the_date, datestr, ReturnFormat, 6));
  61.  
  62.     return(0);
  63. }
  64. /*
  65. void main(void)
  66. {
  67.    char the_date[9]="";
  68.  
  69.    finddate(the_date, 6, 6, "Mail Received Date");
  70. }*/